import { createStore } from 'vuex';

const store = createStore({
    state: {
        message: 'Hello Vuex!',
    },
    mutations: {
        updateMessage(state, payload) {
            state.message = payload;
        },
    },
    actions: {
        asyncUpdateMessage({ commit }, payload) {
            setTimeout(() => {
                commit('updateMessage', payload);
            }, 1000);
        },
    },
    getters: {
        uppercaseMessage: (state) => state.message.toUpperCase(),
    },
});

export default store;
